package com.nf.mvc.handler;

import com.nf.mvc.view.*;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

public class HandlerHelper {

    public static VoidViewResult empty() {
        return new VoidViewResult();
    }

    public static JsonViewResult json(Object data) {
        return new JsonViewResult(data);
    }

    public static PlainViewResult plain(String text) {
        return new PlainViewResult(text);
    }


    public static HtmlViewResult html(String html) {
        return new HtmlViewResult(html);
    }

    public static ForwardViewResult forward(String url) {
        return forward(url, new HashMap<>());
    }

    public static ForwardViewResult forward(String url, Map<String, Object> model) {
        return new ForwardViewResult(url, model);
    }

    public static RedirectViewResult redirect(String url) {
        return redirect(url, new HashMap<>());
    }

    public static RedirectViewResult redirect(String url, Map<String, String> model) {
        return new RedirectViewResult(url, model);
    }

    public static FileViewResult file(String realpath) {
        return new FileViewResult(realpath);
    }

    public static FileViewResult file(InputStream inputStream, String filename) {
        return new FileViewResult(inputStream, filename);
    }
}
